var t = getApp();

Page({
    data: {
        type: "",
        id: 0,
        rewardShow: !1,
        details: {},
        attentionRewaedData: {},
        attentionRewaedShow: !1,
        commentsShow: !1
    },
    onLoad: function(e) {
        e.type && this.setData({
            type: e.type
        }), e.id && (this.data.id = e.id), e.mid && (t._setMid(e.mid), this.sendForwardReward()), 
        this.getDetails();
    },
    setCommentShow: function() {
        this.setData({
            commentsShow: !this.data.commentsShow
        });
    },
    setRewardShow: function() {
        this.setData({
            rewardShow: !this.data.rewardShow
        });
    },
    setAttentionRewaedShow: function() {
        this.setData({
            attentionRewaedShow: !this.data.attentionRewaedShow
        });
    },
    handAttentionRewaed: function(t) {
        this.setData({
            attentionRewaedData: t.detail,
            attentionRewaedShow: !0
        });
    },
    handCommentSuccess: function(t) {
        console.log(t.detail.type);
        var e = t.detail.type, a = this.data.details.comment_count;
        "add" == e ? a++ : "reduce" == e && a--, this.setData({
            "details.comment_count": a
        });
    },
    sendAttention: function() {
        var e = this, a = this.data.details, i = a.is_attention, n = "", d = {};
        i ? (n = t.getNetAddresss("plugin.new-media-advertising.frontend.media-advertisingt.cancel-attention"), 
        d.advertisingt_member = a.member_id) : (n = t.getNetAddresss("plugin.new-media-advertising.frontend.media-advertisingt.attention"), 
        d.advertisingt_id = a.id), t._getNetWork({
            url: n,
            data: d,
            success: function(a) {
                var n = a.data;
                if (1 != n.result) return t.tips(n.msg);
                var d = {};
                d["details.is_attention"] = !i, 1 == n.data.is_reward && (d.attentionRewaedData = n.data, 
                d.attentionRewaedShow = !0), e.setData(d);
            }
        });
    },
    handFavorites: function(t) {
        var e = t.detail.favorites_count, a = t.detail.is_favorites, i = {};
        i["details.is_favorites"] = !a, i["details.favorites_count"] = e, this.setData(i);
    },
    handLike: function(t) {
        var e = t.detail.like_count, a = t.detail.is_like, i = {};
        i["details.is_like"] = !a, i["details.like_count"] = e, this.setData(i);
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    sendForwardReward: function() {
        var e = t.getNetAddresss("plugin.new-media-advertising.frontend.media-advertisingt.forward-reward");
        t._getNetWork({
            url: e,
            data: {
                advertisingt_id: this.data.id
            },
            success: function(e) {
                var a = e.data;
                if (1 != a.result) return t.tips(a.msg);
            }
        });
    },
    onReachBottom: function() {},
    onShareAppMessage: function(t) {
        var e = wx.getStorageSync("yz_uid"), a = "";
        e && (a = e);
        var i = this.data.details, n = "/packageI/newMedia/newMediaAdDetails/newMediaAdDetails?id=" + i.id + "&mid=" + a, d = i.title;
        return console.log(n), {
            path: n,
            title: d
        };
    },
    getDetails: function() {
        var e = this, a = this.data.id, i = t.getNetAddresss("plugin.new-media-advertising.frontend.media-advertisingt.advertisingt-info");
        t._getNetWork({
            url: i,
            data: {
                advertisingt_id: a
            },
            success: function(a) {
                var i = a.data;
                if (1 != i.result) return t.tips(i.msg);
                var n = i.data, d = {
                    details: n,
                    type: [ "", "news", "article", "audio" ][n.genre]
                };
                n.behavioral && n.behavioral.is_reward && 1 == n.behavioral.is_reward && (d.attentionRewaedData = n.behavioral, 
                d.attentionRewaedShow = !0), e.setData(d);
            }
        });
    }
});